﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.master" CodeBehind="Profile.aspx.cs"
    Inherits="CivilRegistry.Profile" %>

<%@ Register Src="~/UserControls/UCUserGadget.ascx" TagName="UserGadget" TagPrefix="UC" %>
<%@ Register Src="~/UserControls/UCAddress.ascx" TagName="AddressControl" TagPrefix="UC" %>
<asp:Content ID="headerContent" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function ViewImageUploader() {
            if ($('#<%=lbChangeImage.ClientID%>').text() == "Change Image") {
                $('#<%=ImageUploader.ClientID%>').css('visibility', 'visible');
                $('#<%=lbChangeImage.ClientID%>').text('Save Image');
                return false;
            }
            else {
                return true;
            }
        }

        $(function () {
            $("#<%=pnlPermanentAddressEdit.ClientID%>").change(function () {
                $("#<%=pnlPermanentAddressEdit.ClientID%>").data("changed", true);
            });

            $("#<%=pnlPresentAddressEdit.ClientID%>").change(function () {
                $("#<%=pnlPresentAddressEdit.ClientID%>").data("changed", true);
            });

        });

        //From here the code should be in CommonScript.js
        function ValidatePage() {
            if (Page_ClientValidate() && ValidatePermanentAddressEdit() && ValidatePresentAddressEdit()) {
                return true;
            }
            else {
                return false;
            }
        }

        function ValidatePermanentAddressEdit() {
            if ($("#<%=pnlPermanentAddressEdit.ClientID%>").data("changed")) {

                if ($("[id*='ucPermanentAddress_FlupldElectricitybill']").val() == "") {
                    $("[id*='ucPermanentAddress_lblValidation']").css('visibility', 'visible');
                    return false;
                }
            }

            if ($("[id*='ucPermanentAddress_txtAddress']").val() != "") {
                if ($("[id*='ucPermanentAddress_txtPIN']").val() == "") {
                    $("[id*='ucPermanentAddress_lblPinValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPermanentAddress_lblPinValidation']").css('visibility', 'hidden');
                if ($("[id*='ucPermanentAddress_txtCity']").val() == "") {
                    $("[id*='ucPermanentAddress_lblCityValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPermanentAddress_lblCityValidation']").css('visibility', 'hidden');
                if ($("[id*='ucPermanentAddress_ddlStateName']").val() == 0 || $("[id*='ucPermanentAddress_ddlStateName']").val() == null) {
                    $("[id*='ucPermanentAddress_lblStateValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPermanentAddress_lblStateValidation']").css('visibility', 'hidden');
                if ($("[id*='ucPermanentAddress_ddlDistrictName']").val() == 0 || $("[id*='ucPermanentAddress_ddlStateName']").val() == null) {
                    $("[id*='ucPermanentAddress_lblDistrictValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPermanentAddress_lblDistrictValidation']").css('visibility', 'hidden');
            }
            return true;
        }

        function ValidatePresentAddressEdit() {
            if ($("#<%=pnlPresentAddressEdit.ClientID%>").data("changed")) {

                if ($("[id*='ucPresentAddress_FlupldElectricitybill']").val() == "") {
                    $("[id*='ucPresentAddress_lblValidation']").css('visibility', 'visible');
                    return false;
                }
            }
            if ($("[id*='ucPresentAddress_txtAddress']").val() != "") {
                if ($("[id*='ucPresentAddress_txtPIN']").val() == "") {
                    $("[id*='ucPresentAddress_lblPinValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPresentAddress_lblPinValidation']").css('visibility', 'hidden');
                if ($("[id*='ucPresentAddress_txtCity']").val() == "") {
                    $("[id*='ucPresentAddress_lblCityValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPresentAddress_lblCityValidation']").css('visibility', 'hidden');
                if ($("[id*='ucPresentAddress_ddlStateName']").val() == 0 || $("[id*='ucPresentAddress_ddlStateName']").val() == null) {
                    $("[id*='ucPresentAddress_lblStateValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPresentAddress_lblStateValidation']").css('visibility', 'hidden');
                if ($("[id*='ucPresentAddress_ddlDistrictName']").val() == 0 || $("[id*='ucPresentAddress_ddlStateName']").val() == null) {
                    $("[id*='ucPresentAddress_lblDistrictValidation']").css('visibility', 'visible');
                    return false;
                }
                $("[id*='ucPresentAddress_lblDistrictValidation']").css('visibility', 'hidden');
            }
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="maincontent" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        &nbsp;<div class="mainContent">
            <asp:Panel ID="pnlNews" runat="server">
            </asp:Panel>
            <center>
                <asp:Label ID="lblStatus" runat="server" BackColor="Yellow" ForeColor="DarkBlue"
                    Font-Bold="true"></asp:Label>
            </center>
            <asp:Panel ID="pnlDisplay" runat="server">
                <div class="form-content">
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblUserId" runat="server" Text="User Id:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblUserIdValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblUserName" runat="server" Text="User Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblUserNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblFirstName" runat="server" Text="First Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblFirstNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblMiddleName" runat="server" Text="Middle Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblMiddleNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblLastName" runat="server" Text="Last Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblLastNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblMotherName" runat="server" Text="Mother Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblMotherNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblFatherName" runat="server" Text="Father Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblFatherNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblGaurdianName" runat="server" Text="Gaurdian Name:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblGaurdianNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblEmailAddress" runat="server" Text="Email Address:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblEmailAddressValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblPhoneNo" runat="server" Text="PhoneNo:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblPhoneNoValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblGender" runat="server" Text="Gender:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblGenderValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblDateOfBirth" runat="server" Text="Date Of Birth:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblDateOfBirthValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblAge" runat="server" Text="Age:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblAgeValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblAddress" runat="server" Text="Address:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblAddressValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblPIN" runat="server" Text="PIN:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblPINValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblCity" runat="server" Text="City:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblCityValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblStateName" runat="server" Text="State:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblStateNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="form-fields clearfix">
                        <div class="fl txtrgt divsize1">
                            <asp:Label ID="lblDistrictName" runat="server" Text="District:"></asp:Label>
                        </div>
                        <div class="fr txtlft divsize2">
                            <asp:Label ID="lblDistrictNameValue" runat="server"></asp:Label>
                        </div>
                    </div>
                    <div class="bottomButtons form-fields clearfix">
                        <asp:LinkButton ID="lbnViewElectricBillXerox" runat="server" OnClick="lbnViewElectricBillXerox_Click">View Electrical Bill Xerox</asp:LinkButton>
                    </div>
                    <div class="bottomButtons" id="divProfileEdit">
                        <asp:Button ID="btnEdit" runat="server" Text="Edit" CssClass="button greenButton medium"
                            OnClick="btnEdit_Click" />
                        <asp:Button ID="btnProfileCancel" runat="server" Text="Cancel" CssClass="button red medium"
                            OnClick="btnProfileCancel_Click" />
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel ID="pnlEdit" runat="server">
                <div class="form-content">
                    <asp:Panel ID="pnlPersonSpecificEdit" runat="server">
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblEmailAddressEdit" runat="server" Text="EmailAddress:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtEmailAddress" runat="server"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtEmailAddress"
                                    CssClass="redText" Display="Static" ErrorMessage="Please enter valid email" Font-Size="Smaller"
                                    Width="99px" Font-Bold="true" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                            </div>
                        </div>
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblPhoneNoEdit" runat="server" Text="PhoneNo:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtPhoneNo" runat="server"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtPhoneNo"
                                    CssClass="redText" Display="Static" ErrorMessage="Please enter valid phone no."
                                    Font-Size="Smaller" Width="99px" Font-Bold="true" ValidationExpression="^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$"></asp:RegularExpressionValidator>
                            </div>
                        </div>
                    </asp:Panel>
                    <asp:Panel ID="pnlAdminSpecificEdit" Visible="false" runat="server">
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblFirstNameEdit" runat="server" Text="First Name:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                            </div>
                        </div>
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblMiddleNameEdit" runat="server" Text="Middle Name:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtMiddleName" runat="server"></asp:TextBox>
                            </div>
                        </div>
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblLastNameEdit" runat="server" Text="Last Name:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                            </div>
                        </div>
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblMotherNameEdit" runat="server" Text="Mother Name:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtMotherName" runat="server"></asp:TextBox>
                            </div>
                        </div>
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblFatherNameEdit" runat="server" Text="Father Name:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtFatherName" runat="server"></asp:TextBox>
                            </div>
                        </div>
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblGaurdianNameEdit" runat="server" Text="Gaurdian Name:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:TextBox ID="txtGaurdianName" runat="server"></asp:TextBox>
                            </div>
                        </div>
                        <div class="form-fields clearfix">
                            <div class="fl txtrgt divsize1">
                                <asp:Label ID="lblGenderEdit" runat="server" Text="Gender:"></asp:Label>
                            </div>
                            <div class="fr txtlft divsize2">
                                <asp:RadioButtonList ID="rblGender" runat="server" RepeatDirection="Horizontal">
                                    <asp:ListItem Text="Male" Value="M"></asp:ListItem>
                                    <asp:ListItem Text="Female" Value="F"></asp:ListItem>
                                </asp:RadioButtonList>
                            </div>
                        </div>
                    </asp:Panel>
                    <asp:Panel ID="pnlPermanentAddressEdit" runat="server">
                        <div class="SideText">
                            Permanet Address:</div>
                        <UC:AddressControl ID="ucPermanentAddress" runat="server" />
                    </asp:Panel>
                    <asp:Panel ID="pnlPresentAddressEdit" runat="server">
                        <div class="SideText">
                            Present Address:</div>
                        <UC:AddressControl ID="ucPresentAddress" runat="server" />
                    </asp:Panel>
                </div>
                <div>
                </div>
                <div class="bottomButtons">
                    <asp:Button ID="btnSave" Text="Save" runat="server" CssClass="button greenButton medium"
                        OnClientClick="return ValidatePage();" OnClick="btnSave_Click" />
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="button red medium"
                        OnClick="btnCancel_Click" ValidationGroup="Different" />
                </div>
            </asp:Panel>
        </div>
        <div class="Gadget">
            <UC:UserGadget ID="ucUserGadget" runat="server" />
            <center>
                <asp:FileUpload ID="ImageUploader" runat="server" Style="visibility: hidden;" /><asp:LinkButton
                    ID="lbChangeImage" OnClientClick="return ViewImageUploader();" Text="Change Image"
                    OnClick="lbChangeImage_Click" runat="server"></asp:LinkButton>
            </center>
        </div>
    </div>
</asp:Content>
